﻿#include "builder.h"
#include <iostream>

void ClientCode(Director &director)
{
    {
        ConcreteBuilder1 *builder = new ConcreteBuilder1();
        director.set_builder(builder);
        std::cout << "Standard basic product:\n";
        director.buildMinimalViableProduct();

        Product1 *p = builder->GetProduct();
        p->ListParts();
        delete p;
        delete builder;
    }

    {
        ConcreteBuilder2 *builder = new ConcreteBuilder2();
        std::cout << "Standard full featured product:\n";
        director.buildFullFeaturedProduct();

        Product2 *p = builder->GetProduct();
        p->ListParts();
        delete p;
        delete builder;
    }

    // Remember, the Builder pattern can be used without a Director class.
    {
        ConcreteBuilder1 *builder = new ConcreteBuilder1();
        std::cout << "Custom product:\n";
        builder->producePartA();
        builder->producePartC();
        Product1 *p = builder->GetProduct();
        p->ListParts();
        delete p;
        delete builder;
    }
}

int main()
{
    Director d = Director();
    ClientCode(d);

    return 0;
}